<?php
/**
 * Created by PhpStorm.
 * User: zhenl
 * Date: 2022/10/21
 * Time: 10:57
 */

namespace app\api\controller;


use app\BaseController;
use app\Request;
use think\Cache;
use think\helper\Str;

class Util extends BaseController
{

    public function generateCode(Request $request)
    {
        $param = $request->param();
        $text = Str::random(6, 1);

        // key规则code-手机号-场景，举例code-15605009999-2
        cache("code-{$param['scene']}-{$param['mobile']}", $text, 300);

        return json([
            'code' => 0,
            'msg' => '成功',
            'data' => $text
        ]);
    }
}